package com.itheima.article.controller;


import com.itheima.article.pojo.ApAuthor;
import com.itheima.article.service.ApAuthorService;
import com.itheima.common.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ApiController {

    @Autowired
    private ApAuthorService apAuthorService;


    /**
     * 通过用户id与自媒体账号id获取作者信息
     * @param apUserId 用户id
     * @param wmUserId 自媒体账号id
     * @return
     */
    @GetMapping("/api/apAuthor/{apUserId}/{wmUserId}")
    public ResultVo<ApAuthor> getByApUserIdWmUserId(
            @PathVariable(name = "apUserId")Integer apUserId,
            @PathVariable(name = "wmUserId")Integer wmUserId){
        ApAuthor apAuthor = apAuthorService.vbgetByApUserIdWmUserId(apUserId,wmUserId);
        return ResultVo.ok(apAuthor);
    }



    /**
     * 创建自媒体账号
     * @param apAuthor
     * @return
     */
    @PostMapping("/api/apAuthor/add")
    public ResultVo add(@RequestBody ApAuthor apAuthor){
        apAuthorService.save(apAuthor);
        return ResultVo.ok();
    }


}
